public class Test {
    //一、使用Comparable接口
    public static void main1(String[] args) {
        Student student1 = new Student("zhangsan",18,90.12);
        Student student2 = new Student("lisi",20,85.26);
        System.out.println(student1);
        System.out.println(student2);

        //要想比较student1和student2的大小关系，
        //需要Student类实现Comparable接口，并实现其中的compareTo方法
        System.out.println(student1.compareTo(student2));
        if(student1.compareTo(student2) > 0){
            System.out.println("s1 > s2");
        } else if(student1.compareTo(student2) == 0){
            System.out.println("s1 = s2");
        }else System.out.println("s1 < s2");
    }

    //二、使用Comparator接口
    public static void main2(String[] args) {
        Student student1 = new Student("zhangsan",10,89.3);
        Student student2 = new Student("lisi",5,90.29);

        ScoreComparator scoreComparator = new ScoreComparator();
        int ret1 = scoreComparator.compare(student1,student2);
        if(ret1 > 0){
            System.out.println("成绩关系：s1 > s2");
        } else {
            System.out.println("成绩关系：s1 < s2");
        }

        AgeComparator ageComparator = new AgeComparator();
        int ret2 = ageComparator.compare(student1,student2);
        if(ret2 > 0){
            System.out.println("年龄关系：s1 > s2");
        } else {
            System.out.println("年龄关系：s1 < s2");
        }

        NameComparator nameComparator = new NameComparator();
        int ret3 = ageComparator.compare(student1,student2);
        if(ret3 > 0){
            System.out.println("姓名关系：s1 > s2");
        } else {
            System.out.println("姓名关系：s1 < s2");
        }
    }

}
